package com.tjbklx1.redisTest.replace;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

public class ReplaceContext {

		public static void main(String[] args) throws IOException {
//			read("E:\\Pic\\1.txt", "E:\\Pic\\1W.txt");
//			read("E:\\Pic\\2.txt", "E:\\Pic\\2W.txt");
//			read("E:\\Pic\\3.txt", "E:\\Pic\\3W.txt");
//			read("E:\\Pic\\4.txt", "E:\\Pic\\4W.txt");
//			read("E:\\Pic\\5.txt", "E:\\Pic\\5W.txt");
//			read("E:\\Pic\\6.txt", "E:\\Pic\\6W.txt");
//			read("E:\\Pic\\7.txt", "E:\\Pic\\7W.txt");
//			read("E:\\Pic\\8.txt", "E:\\Pic\\8W.txt");
//			read("E:\\Pic\\9.txt", "E:\\Pic\\9W.txt");
//			read("E:\\Pic\\10.txt", "E:\\Pic\\10W.txt");
//			read("E:\\Pic\\11.txt", "E:\\Pic\\11W.txt");
			
//			read("E:\\Pic\\12.txt", "E:\\Pic\\12W.txt");
//			read("E:\\Pic\\13.txt", "E:\\Pic\\13W.txt");
//			read("E:\\Pic\\14.txt", "E:\\Pic\\14W.txt");
//			read("E:\\Pic\\15.txt", "E:\\Pic\\15W.txt");
//			read("E:\\Pic\\16.txt", "E:\\Pic\\16W.txt");
//			read("E:\\Pic\\17.txt", "E:\\Pic\\17W.txt");
//			read("E:\\Pic\\18.txt", "E:\\Pic\\18W.txt");
//			read("E:\\Pic\\19.txt", "E:\\Pic\\19W.txt");
//			read("E:\\Pic\\20.txt", "E:\\Pic\\20W.txt");
//			read("E:\\Pic\\21.txt", "E:\\Pic\\21W.txt");
//			read("E:\\Pic\\22.txt", "E:\\Pic\\22W.txt");
//			read("E:\\Pic\\23.txt", "E:\\Pic\\23W.txt");
//			read("E:\\Pic\\24.txt", "E:\\Pic\\24W.txt");
//			read("E:\\Pic\\25.txt", "E:\\Pic\\25W.txt");
//			read("E:\\Pic\\26.txt", "E:\\Pic\\26W.txt");
//			read("E:\\Pic\\27.txt", "E:\\Pic\\27W.txt");
//			read("E:\\Pic\\28.txt", "E:\\Pic\\28W.txt");
//			read("E:\\Pic\\29.txt", "E:\\Pic\\29W.txt");
//			read("E:\\Pic\\30.txt", "E:\\Pic\\30W.txt");
//			read("E:\\Pic\\31.txt", "E:\\Pic\\31W.txt");
			
			
//			read("E:\\Pic\\32.txt", "E:\\Pic\\32W.txt");
//			read("E:\\Pic\\33.txt", "E:\\Pic\\33W.txt");
//			read("E:\\Pic\\34.txt", "E:\\Pic\\34W.txt");
//			read("E:\\Pic\\35.txt", "E:\\Pic\\35W.txt");
//			read("E:\\Pic\\36.txt", "E:\\Pic\\36W.txt");
//			read("E:\\Pic\\37.txt", "E:\\Pic\\37W.txt");
//			read("E:\\Pic\\38.txt", "E:\\Pic\\38W.txt");
//			read("E:\\Pic\\39.txt", "E:\\Pic\\39W.txt");
//			read("E:\\Pic\\40.txt", "E:\\Pic\\40W.txt");
//			read("E:\\Pic\\41.txt", "E:\\Pic\\41W.txt");
//			read("E:\\Pic\\41.txt", "E:\\Pic\\42W.txt");
			
			
			read("E:\\Pic\\43.txt", "E:\\Pic\\43W.txt");
			
			
		}
	
		public static void read(String input ,String output) throws IOException {
			//读取文件(字节流)
	        InputStream in = new FileInputStream(input);
	        //写入相应的文件
	        OutputStream out = new FileOutputStream(output);
	        //读取数据
	        //一次性取多少字节
	        byte[] bytes = new byte[2048];
	        //接受读取的内容(n就代表的相关数据，只不过是数字的形式)
	        int n = -1;
	        //循环取出数据
	        while ((n = in.read(bytes,0,bytes.length)) != -1) {
	            //转换成字符串
	            String str = new String(bytes,0,n,"UTF-8"); //这里可以实现字节到字符串的转换，比较实用
	            System.out.println(str);
	            str = replace(str);
	            //写入相关文件
	            out.write(str.getBytes(), 0, str.getBytes().length);
	        }
	        //关闭流
	        in.close();
	        out.close();
		}

		private static String replace(String str) {
			str = str.replace("<p>", "");
			str = str.replace("</p>", "");
			str = str.replace("</h2>", "");
			str = str.replace("<h2 class=\"heading\" data-id=\"heading-3\">", "");
			str = str.replace("<pre>", "");
			str = str.replace("</pre>", "");
			str = str.replace("<code class=\"hljs bash\" lang=\"bash\">", "");
			str = str.replace("<span class=\"hljs-keyword\">", "");
			str = str.replace("<span class=\"hljs-built_in\">", "");
			str = str.replace("&gt;", ">");
			str = str.replace("&lt;", ">");
			str = str.replace("<span class=\"hljs-literal\">", "");
			str = str.replace("</code>", "");
			str = str.replace("<h2 class=\"heading\" data-id=\"heading-2\">", "\r\n");
			str = str.replace("<code class=\"hljs py\" lang=\"py\">", "\r\n");
			str = str.replace("<span class=\"hljs-comment\">", "");
			str = str.replace("<span class=\"hljs-function\">", "");
			str = str.replace("<span class=\"hljs-title\">", "");
			str = str.replace("<span class=\"hljs-params\">", "");
			str = str.replace("<span class=\"hljs-title\">", "");
			str = str.replace("<span class=\"hljs-number\">", "");
			str = str.replace("<span class=\"hljs-string\">", "");
			str = str.replace("<span class=\"hljs-string\">", "");
			str = str.replace("<span class=\"hljs-class\">", "");
			str = str.replace("<code class=\"hljs java\" lang=\"java\">", "\r\n");
			str = str.replace("<div data-v-41acfafa=\"\" class=\"entry-content article-content\">", "");
			str = str.replace("<h1 class=\"heading\" data-id=\"heading-0\">", "");
			str = str.replace("<strong>", "");
			str = str.replace("</strong>", "");
			str = str.replace("<figure>", "");
			str = str.replace("</figure>", "");
			str = str.replace("<figcaption>", "");
			str = str.replace("</figcaption>", "");
			str = str.replace("<code class=\"hljs lua\" lang=\"lua\">", "");
			str = str.replace("<h2 class=\"heading\" data-id=\"heading-4\">", "\r\n");
			str = str.replace("<ol>", "");
			str = str.replace("</ol>", "");
			str = str.replace("<li>", "\t");
			str = str.replace("</li>", "");
//			str = str.replace("<a target=\"_blank\" href=\"", "");
//			str = str.replace("<section data-v-41acfafa=\"\" class=\"book-comments\"><div data-v-41acfafa=\"\" class=\"box-title\">", "");
//			str = str.replace("<div data-v-41acfafa=\"\" class=\"comment-box\">", "");
//			str = str.replace("<div data-v-efcd2e56=\"\" data-v-41acfafa=\"\" class=\"comment-form comment-form\" id=\"comment\">", "");
//			str = str.replace("<div data-v-b2db8566=\"\" data-v-1b9df826=\"\" data-v-efcd2e56=\"\" data-src=\"https://thirdwx.qlogo.cn/mmopen/vi_32/GViaFficKDl6lUMc0dRNut5iawtn3oq6cUiakBdh85qz3W9YX8Xf9mRnTvrHAFDPicFI5OPWaqdk6LmCgqfY8fW3log/132\" class=\"lazy avatar avatar loaded\" style=\"background-image: url(&quot;https://thirdwx.qlogo.cn/mmopen/vi_32/GViaFficKDl6lUMc0dRNut5iawtn3oq6cUiakBdh85qz3W9YX8Xf9mRnTvrHAFDPicFI5OPWaqdk6LmCgqfY8fW3log/132&quot;);\" title=\"\">", "");
//			str = str.replace("<textarea data-v-efcd2e56=\"\" placeholder=\"评论将在后台进行审核，审核通过后对所有人可见\" class=\"content-input\" style=\"overflow: hidden; overflow-wrap: break-word; height: 62px;\"></textarea>", "");
//			str = str.replace("<div data-v-efcd2e56=\"\" class=\"action-box\" style=\"display: none;\">", "");
//			str = str.replace("<div data-v-54e3f196=\"\" data-v-efcd2e56=\"\" class=\"image-uploader image-uploader\" style=\"display: none;\">", "");
//			str = str.replace("<input data-v-54e3f196=\"\" class=\"input\" type=\"file\">", "");
//			str = str.replace("<button data-v-54e3f196=\"\" class=\"upload-btn\">", "");
//			str = str.replace("<i data-v-54e3f196=\"\" class=\"icon ion-image\">", "");
//			str = str.replace("<span data-v-54e3f196=\"\">上传图片", "");
//			str = str.replace("<span data-v-54e3f196=\"\">", "");
//			str = str.replace("<div data-v-efcd2e56=\"\" class=\"submit-box\"><span data-v-efcd2e56=\"\" class=\"submit-text\">", "");
//			str = str.replace("Ctrl or ⌘ + Enter", "");
//			str = str.replace("<button data-v-efcd2e56=\"\" class=\"submit-btn\">", "\r\n");
//			str = str.replace("<ul data-v-51163f89=\"\" data-v-41acfafa=\"\" st:block=\"commentList\" class=\"comment-list comment-list\">", "");
//			str = str.replace("\"><li data-v-51163f89=\"\" class=\"item\">", "");
//			str = str.replace("<div data-v-7f6a837b=\"\" data-v-51163f89=\"\" class=\"comment\">", "");
//			str = str.replace("<div data-v-311d2efa=\"\" data-v-7f6a837b=\"\" st:block=\"userPopover\" st:state=\"5b8fc46cf265da0a8d366af2\" class=\"user-popover-box\">", "");
//			str = str.replace("<span data-v-7f6a837b=\"\" class=\"content-html\">", "");
//			str = str.replace("</a>", "");
//			str = str.replace("<div data-v-7f6a837b=\"\" class=\"position\">", "");
//			str = str.replace("<div data-v-7f6a837b=\"\" class=\"content\">", "");
//			str = str.replace("<span data-v-7f6a837b=\"\" class=\"content-html\">", "");
//			str = str.replace("target=\"_blank\" rel=\"\" class=\"username\" data-v-311d2efa=\"\">", "");
//			str = str.replace("<a data-v-7f6a837b=\"\" ", "");
//			str = str.replace("<div data-v-311d2efa=\"\" data-v-7f6a837b=\"\" st:block=\"userPopover\" st:state=\"5b486123e51d45198a2eba4f\" class=\"user-popover-box\">", "");
//			str = str.replace("<div data-v-6fdfc18a=\"\" class=\"content\">", "");
//			str = str.replace("<span data-v-6fdfc18a=\"\" class=\"content-html\">", "");
//			str = str.replace("<div data-v-6fdfc18a=\"\" class=\"position\">", "");
//			str = str.replace("<a data-v-6fdfc18a=\"\"", "");
//			str = str.replace("<div data-v-311d2efa=\"\" data-v-6fdfc18a=\"\" st:block=\"userPopover\" st:state=\"5a9c4a13f265da23826d733a\" class=\"user-popover-box user-popover--info\">", "");
//			str = str.replace("", "");
//			str = str.replace("", "");
			str = str.replace("</blockquote>", "");
			str = str.replace("<blockquote>", "");
			str = str.replace("<hr>", "");
			str = str.replace("<h4 class=\"heading\" data-id=\"heading-8\">", "");
			str = str.replace("<h4 class=\"heading\" data-id=\"heading-9\">", "");
			str = str.replace("<a target=\"_blank\" href=\"", "");
			str = str.replace("</a>", "");
			str = str.replace("</h4>", "");
			str = str.replace("<h2 class=\"heading\" data-id=\"heading-5\">", "\r\n");
			str = str.replace("<h4 class=\"heading\" data-id=\"heading-6\">", "");
			str = str.replace("<h4 class=\"heading\" data-id=\"heading-7\">", "");
			str = str.replace("<h4 class=\"heading\" data-id=\"heading-8\">", "");
			str = str.replace("<code>", "");
			str = str.replace("<h2 class=\"heading\" data-id=\"heading-9\">", "");
			str = str.replace("<h2 class=\"heading\" data-id=\"heading-11\">", "");
			str = str.replace("<h2 class=\"heading\" data-id=\"heading-10\">", "");
			str = str.replace("<h2 class=\"heading\" data-id=\"heading-11\">", "");
			str = str.replace("</ul>", "");
			str = str.replace("<ul>", "");
			str = str.replace("&quot;", "");
			str = str.replace("src=\"data:image/svg+xml;utf8,", "");
			str = str.replace("<?xml version=1.0?>", "");
			str = str.replace("data-height=\"156\"", "");
			str = str.replace("class=\"lazyload inited\" 	", "");
			str = str.replace("</h1>", "\r\n");
			str = str.replace("<h2 class=\"heading\" data-id=\"heading-1\">", "\r\n");
			str = str.replace("<span class=\"hljs-string\">", "");
			str = str.replace("<code class=\"hljs bash\" lang=\"bash\">", "");
			str = str.replace("<span class=\"hljs-variable\">", "");
			str = str.replace("<span class=\"hljs-string\">", "");
			str = str.replace("<h4 class=\"heading\" data-id=\"heading-4\">", "");
			str = str.replace("<h4 class=\"heading\" data-id=\"heading-5\">", "");
			str = str.replace("class=\"lazyload inited\"", "");
			str = str.replace("", "");
			str = str.replace("", "");
			str = str.replace("", "");
			str = str.replace("", "");
			str = str.replace("", "");
			str = str.replace("", "");
			str = str.replace("", "");
			str = str.replace("", "");
			str = str.replace("", "");
			str = str.replace("", "");
			str = str.replace("", "");
			str = str.replace("", "");
			str = str.replace("", "");
			str = str.replace("", "");
			str = str.replace("", "");
			str = str.replace("", "");
			str = str.replace("", "");
			str = str.replace("", "");
			str = str.replace("", "");
			str = str.replace("", "");
			str = str.replace("", "");
			str = str.replace("", "");
			str = str.replace("", "");
			str = str.replace("", "");
			str = str.replace("", "");
			str = str.replace("", "");
			str = str.replace("", "");
			str = str.replace("", "");
			str = str.replace("", "");
			str = str.replace("", "");
			str = str.replace("", "");
			str = str.replace("", "");
			str = str.replace("", "");
			str = str.replace("", "");
			str = str.replace("", "");
			
			
			str = str.replace("rel=\"nofollow noopener noreferrer\">", "");
			str = str.replace("</button>", "");
			str = str.replace("<span data-v-7f6a837b=\"\">", "");
			str = str.replace("</i>", "");
			str = str.replace("<i data-v-7f6a837b=\"\" class=\"collection-arrow-ion ion-arrow-up-b\">", "");
			str = str.replace("<button data-v-7f6a837b=\"\" class=\"like-btn\">", "");
			str = str.replace("<div data-v-7f6a837b=\"\" class=\"footer\">", "");
			str = str.replace("<!---->", "");
			str = str.replace("</span>", "");
			str = str.replace("</div>", "");
			return str;
		}
	
}
